package cn.org.xiaoweiba.graduationdesign.bookmall.service.impl;

import cn.org.xiaoweiba.graduationdesign.bookmall.constant.ResponseResultMessageConstant;
import cn.org.xiaoweiba.graduationdesign.bookmall.dto.RSAKeyPair;
import cn.org.xiaoweiba.graduationdesign.bookmall.dto.result.BaseResponseResult;
import cn.org.xiaoweiba.graduationdesign.bookmall.dto.result.OkResponseResult;
import cn.org.xiaoweiba.graduationdesign.bookmall.service.RSAService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * RSA 相关的业务层
 */
@Service
public class RSAServiceImpl implements RSAService {

    /**
     * 通用的 RSA 密钥对
     */
    @Autowired
    private RSAKeyPair rsaCommonKeyPair;

    /**
     * 获取通用的 RSA 公钥
     *
     * @return 通用的 RSA 公钥
     */
    @Override
    public BaseResponseResult<Object> getRSACommonPublicKey() {
        return OkResponseResult.okResult(
                ResponseResultMessageConstant.GET_RSA_COMMON_PUBLIC_KEY_SUCCESS,
                rsaCommonKeyPair.getPublicKey()
        );
    }
}
